package com.itboye.sunsun.adapter;

import java.util.ArrayList;

import com.itboye.sunsun.R;
import com.itboye.sunsun.address.AqriumModel;

import android.content.Context;
import android.graphics.Bitmap;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

/***
 * 水族馆
 * 
 * @author l
 * 
 */
public class AqriumAdapter extends BaseAdapter {
	ArrayList<AqriumModel> mList;
	Context mContext;
	int op = 0;

	public AqriumAdapter(ArrayList<AqriumModel> mList, Context mContext) {
		this.mList = mList;
		this.mContext = mContext;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList == null ? 0 : mList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return mList == null ? 0 : mList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;

	}

	@Override
	public View getView(int arg0, View convertView, ViewGroup arg2) {
		HandView mHandView = null;

		if (convertView == null) {
			mHandView = new HandView();

			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.aquarium_item, null);
			mHandView.hed = (ImageView) convertView
					.findViewById(R.id.img_am_hed);
			mHandView.name = (TextView) convertView.findViewById(R.id.am_name);
			mHandView.content = (TextView) convertView
					.findViewById(R.id.am_content);
			mHandView.leift = (ImageView) convertView
					.findViewById(R.id.img_am_leit);
			mHandView.centet = (ImageView) convertView
					.findViewById(R.id.img_am_centet);
			mHandView.right = (ImageView) convertView
					.findViewById(R.id.img_am_gheit);
			mHandView.imgtime = (ImageView) convertView
					.findViewById(R.id.img_am_time);
			mHandView.time = (TextView) convertView
					.findViewById(R.id.text_time_qm);
			mHandView.ping = (ImageView) convertView
					.findViewById(R.id.post_item_ping);
			mHandView.zan = (ImageView) convertView
					.findViewById(R.id.post_item_zan);
			mHandView.amping = (TextView) convertView
					.findViewById(R.id.post_ping);
			mHandView.amzan = (TextView) convertView
					.findViewById(R.id.post_zan);
			convertView.setTag(mHandView);

		} else {
			mHandView = (HandView) convertView.getTag();
		}
		// 赋值
		mHandView.hed.setImageBitmap(mList.get(arg0).getHed());
		mHandView.name.setText(mList.get(arg0).getName());
		mHandView.content.setText(mList.get(arg0).getContent());
		mHandView.leift.setImageBitmap(mList.get(arg0).getLeift());
		mHandView.centet.setImageBitmap(mList.get(arg0).getCentet());
		mHandView.right.setImageBitmap(mList.get(arg0).getRight());
		mHandView.imgtime.setImageBitmap(mList.get(arg0).getImgtime());
		mHandView.time.setText(mList.get(arg0).getTime());
		mHandView.ping.setImageBitmap(mList.get(arg0).getPing());
		mHandView.zan.setImageBitmap(mList.get(arg0).getZan());
		mHandView.amping.setText(mList.get(arg0).getAmping());
		mHandView.amzan.setText(mList.get(arg0).getAmzan());
		return convertView;
	}

	class HandView {
		private TextView name;
		private TextView content;
		private TextView time;
		private TextView amping;
		private TextView amzan;
		private ImageView hed;
		private ImageView imgtime;
		private ImageView ping;
		private ImageView zan;
		private ImageView leift;
		private ImageView centet;
		private ImageView right;
	}

}
